<?php
// For old site
$get = array_keys($_GET);
if(preg_match('/^(uid|action|viewnews).*$/', $get[0])) {
	header('location: index2.php?'.$get[0], true, 301);
}

$framework = dirname(__FILE__).'/framework/yii.php';
$config = dirname(__FILE__).'/protected/config/main.php';
// remove the following line when in production mode
define('YII_DEBUG', false);
//defined('YII_DEBUG') or define('YII_DEBUG', true);

// Includes the framework and creates the web application
require($framework);
$webApp = Yii::createWebApplication($config);

// The consts of site
require(dirname(__FILE__).'/protected/config/appConst.php');
// Params of site
$params = require(dirname(__FILE__).'/protected/config/params.php');
Yii::app()->setParams($params);

// Includes the process script file
require(dirname(__FILE__).'/protected/config/common.php');

// For URL rewrite
if(isset($_GET[Yii::app()->getUrlManager()->routeVar])) {
	Yii::app()->getUrlManager()->setUrlFormat('get');
}

// Loads administrator's config if there is a request to admin console panel
$reqPathInfo = strtolower(Yii::app()->request->pathInfo);
$request2Admin = (strrpos($reqPathInfo, 'admin') === 0);
if($request2Admin) {
	require(dirname(__FILE__).'/protected/config/admin.php');
	if($reqPathInfo === 'admin') {
		$webApp->runController('/admin/posts');
	}
}
// Sychronization with Discuz!
require('config.inc.php');
require('uc_client'.DIRECTORY_SEPARATOR.'client.php');

error_reporting(E_ALL);
//error_reporting(0);
initJsVar();
$webApp->run();
